  <!-- Right side column. Contains the navbar and content of the page -->
            <aside class="right-side">                
                <!-- Content Header (Page header) -->
                <section class="content-header">
                    <h1>
                        Clients
                        <small>Control panel</small>
                    </h1>
                    <ol class="breadcrumb">
                        <li><a href="<?=site_url()?>"><i class="fa fa-dashboard"></i> Accueil</a></li>
                        <li >Dossiers</li>
                        <li class="active">Clients</li>
                    </ol>
                </section>

                <!-- Main content -->
                <section class="content">
                     <div class="row">
                       <div class="col-xs-12">
                                <a class="btn btn-app" href="<?=site_url()?>customers/addCustomer"><i class="fa fa-plus-circle"> </i>Nouveau Client</a>
                                </div>
                        <div class="col-xs-12">
				             <div class="box">
                                <div class="box-header">
                              
                                </div><!-- /.box-header -->
                                <div class="box-body table-responsive">
                                <div class="toolbar"></div>
                                    <table id="example2" class="table table-bordered  table-hover display"   cellspacing="0" width="100%">
                                        <thead>
                                            <tr>                                       
                                                <th>NOM</th>
                                                <th>PRENOM</th>
                                                <th>GSM</th>
                                                <th>EMAIL</th>
                                                <th>ADRESSE</th>
                                                <th>TITRE</th>
                                                <th>Date de Naissance</th>
                                                <th>Langue</th>
                                                <th>Date de Création</th>
                                                <th>STATUS</th>
                                               
                                               
                                            </tr>
                                        </thead>
                                        <tbody>
                 							<?php foreach ($customers as $c):?>
                 							
                 							<tr class="test <?php if($c->statut_id == 2){?>info<?php }elseif($c->statut_id == 3){?>danger<?php }?>" id="tbl_<?=$c->id?>" data-child-comment="<?=$c->comment?>"  data-child-id="<?=$c->id?>" data-child-proprety="111" data-child-propretyId="1">
                 								
                 								<td><a href="#" id="lastname"  data-type="text" data-pk="<?=$c->id?>" data-url="<?=site_url()?>customers/modification" data-title="Nom"><?=$c->lastname?></a> </td>
                 								<td><a href="#" id="firstname"  data-type="text" data-pk="<?=$c->id?>" data-url="<?=site_url()?>customers/modification" data-title="Prénom"><?=$c->firstname?></a></td>
                 								<td><a href="#" id="telephone"  data-type="text" data-pk="<?=$c->id?>" data-url="<?=site_url()?>customers/modification" data-title="GSM"><?=$c->telephone?></a></td>
                 								<td><a href="#" id="email"  data-type="text" data-pk="<?=$c->id?>" data-url="<?=site_url()?>customers/modification" data-title="email"><?=$c->email?></a></td>
                 								<td><a href="#" id="address"  data-type="textarea" data-pk="<?=$c->id?>" data-url="<?=site_url()?>customers/modification" data-title="Nom"><?=$c->address?></a></td>
                 								<td><a href="#" id="gender_id" data-type="select" data-pk="<?=$c->id?>" data-value="<?=$c->gender_id?>" data-url="<?=site_url()?>customers/modification" data-source="<?=site_url()?>customers/selectData/gender" title="Titre"><?=$c->gender->gender?></a> </td>
                 								<td><a href="#" id="birth" data-type="date" data-pk="<?=$c->id?>" data-url="<?=site_url()?>customers/modification" data-title="Select date"><?php if($c->birth){echo date('Y-m-d',strtotime($c->birth));}?></a> <small>(format: aaaa-mm-jj )</small></td>
                 								<td><a href="#" id="lang_id" data-type="select" data-pk="<?=$c->id?>" data-value="<?=$c->lang_id?>" data-url="<?=site_url()?>customers/modification" data-source="<?=site_url()?>customers/selectData/lang" title="Titre"><?=$c->lang->lang?></a> </td>
                 								<td><?=date('d-M-Y H:i',strtotime($c->date_create))?></td>
                 								<td><a href="#" id="statut_id" data-type="select" data-pk="<?=$c->id?>" data-value="<?=$c->statut_id?>" data-url="<?=site_url()?>customers/modification" data-source="<?=site_url()?>customers/selectData/statut" title="Titre"><?=$c->statut->statut?></a> <?php if($this->aauth->is_admin()){?>-  <button type="button" class="btn btn-xs btn-default" onclick="deleteCustomer('<?=$c->id?>')"><i class="fa fa-trash-o"></i> </button><?php }?></td>
                 								
                 								
                 								
                 							</tr>
                 							
											
						<?php endforeach;?>
                                        </tbody>                                     
                                    </table>
                                    <div class="clearfix"></div>
                                </div><!-- /.box-body -->
                            </div><!-- /.box -->
                            </div>
                            </div>
                            
                </section><!-- /.content -->
            </aside><!-- /.right-side -->
        </div><!-- ./wrapper -->
        
         <!-- Modal -->
<div class="modal fade" id="deleteCustomer" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
        <h4 class="modal-title" id="myModalLabel">Supprimer contact</h4>
      </div>
      <div class="modal-body">
        Vous voulez supprimer ce contact ?
      </div>
      <div class="modal-footer">
       	
       
      </div>
    </div>
  </div>
</div>
        
        
<script>

   $(function() {

	              var table = $('#example2').dataTable({
						"language" : {
							"url" : "<?=base_url()?>resources/ajax/data/lang_fr.json"
						},
						"sDom": 'T<"clear">lfrtip',
						"oTableTools": {
							 "sSwfPath": "<?=base_url()?>resources/bootstrap/js/plugins/datatables/TableTools/swf/copy_csv_xls_pdf.swf",
				            "aButtons": [
				              
				                "xls",
				                {
				                    "sExtends": "pdf",
				                    "sPdfOrientation": "landscape"
				                },
				                {
				                    "sExtends":    "collection",
				                    "sButtonText": "Save",
				                    "aButtons":    [ "csv", "xls", "pdf" ]
				                }
				            ]
				        }
						

					}).api();
	           

                
	                
	                //x-editble
	               
	                $('.test a').editable({
							mode:'inline',
							emptytext:'- vide -',
							success:function(response, newValue){
								var obj = jQuery.parseJSON (response);
								if(obj.name =='statut_id' ){
									$('#tbl_'+obj.id).removeClass('danger').removeClass('info');
									if(newValue == 3){
										$('#tbl_'+obj.id).addClass('danger');
										}else if(newValue == 2){
											$('#tbl_'+obj.id).addClass('info');
										}
								}
		                }
	                });
            });

   function deleteCustomer($id)
   {
	   $('#deleteCustomer').modal({
		  keyboard: false
		});
	   $("#deleteCustomer .modal-footer").html(' <button type="button" class="btn btn-default" data-dismiss="modal">Non</button> <button id="deleteBtn" type="button" class="btn btn-danger" data-loading-text="traitement..." onclick = "do_delete('+$id+')" >OUI</button>');
	   }

	function do_delete($id)
	{
		
		var btn = $("#deleteBtn");
	    btn.button('loading');
		$.ajax({
			  async: false, 	
			  type: 'POST',
			  url: '<?=site_url()?>customers/deleteCustomer',
			  data: {id: $id},
			  success: function(data){
					
					btn.button('reset');
					$('#tbl_'+$id).remove();
					$('#subTbl_'+$id).remove();
					$("#deleteCustomer .modal-body p").html('<span class="text-red">Ce contact a été effacé.</span>');
					$("#deleteCustomer .modal-footer").html(' <button type="button" class="btn btn-default" data-dismiss="modal">Fermer</button> ');
				  },
			  dataType: 'json'
			});
	}


   
</script>